<?php
/**
 * Created by JetBrains PhpStorm.
 * User: zhouyang
 * Date: 13-7-15
 * Time: 下午4:31
 * To change this template use File | Settings | File Templates.
 */
class UsersModel extends Model{
    /**
     * @tudo 用户登录检查
     * @param $account
     * @param $password
     * @return array|mixed
     */
    public function login($account,$password){
        $row = $this->dbreader()->login($account,$password);

        return $row;
    }

    /**
     * @tudo 根据用户ID获取用户信息
     * @param $user_id
     * @return array|mixed
     */
    public function getUserById($user_id){
        $row = $this->dbreader()->getUserById($user_id);

        return $row;
    }

    /**
     * @tudo 根据用户名获取用户信息
     * @param $account
     * @return array|mixed
     */
    public function getUserByAccout($account){
        $row = $this->dbreader()->getUserByAccout($account);

        return $row;
    }

    //获取用户所有的权限分类ID
    public function getUserCateIds($user_id){
        $row = $this->dbreader()->getUserCateIds($user_id);

        return $row;
    }

    //是否有权限
    public function isAction($action_url,$user_id = ''){
        $ret = $this->dbreader()->isAction($action_url,$user_id);
        return $ret;
    }

    public function loginUser($username,$password){
        $row = $this->dbreader()->loginUser($username,$password);

        return $row;
    }

    public function addUser($account,$password,$email ,$tel = ''){
        $ret = $this->dbreader()->addUser($account,$password,$email ,$tel);

        return $ret;
    }

    public function updateUser($user_id,$account,$password,$email = '',$tel = ''){
        $ret = $this->dbreader()->updateUser($user_id,$account,$password,$email ,$tel);

        return $ret;
    }

    public function delUser($user_id){
        $ret = $this->dbreader()->delUser($user_id);

        return $ret;
    }

    public function getUserList($curr_page = 1 ,$per_page = 50,$filter = array()){
        $ret = $this->dbreader()->getUserList($curr_page ,$per_page,$filter);

        return $ret;
    }

    public function getUsers($is_stop = null){
        $ret = $this->dbreader()->getUsers($is_stop);

        return $ret;
    }

    public function getRoleUsers($role_id){
        $ret = $this->dbreader()->getRoleUsers($role_id);

        return $ret;
    }

    public function loginlog($user_id){
        $ret = $this->dbreader()->loginlog($user_id);

        return $ret;
    }

    public function getUserCates($user_id){

        $ret = $this->dbreader()->getUserCates($user_id);

        return $ret;
    }

    public function getUserRoles($user_id){

        $ret = $this->dbreader()->getUserRoles($user_id);

        return $ret;
    }

    public function isSuperAdmin($user_id){
        $ret = $this->dbreader()->isSuperAdmin($user_id);

        return $ret;
    }

    public function updateUserName($user_id,$user_name){
        $ret = $this->dbreader()->updateUserName($user_id,$user_name);

        return $ret;
    }
}